package com.kly.sc.api.application.remote.req;

import com.fqgj.common.utils.StringUtils;
import com.kly.sc.api.application.enums.SwitchTypeEnum;
import com.kly.sc.api.infras.app.RequestBasicInfo;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class SwitchManageListReq {
    private String packageName;
    private SwitchTypeEnum switchType;
    private String appVersionName;
    private Integer appVersion;

    public static SwitchManageListReq from(SwitchTypeEnum switchType, RequestBasicInfo requestBasicInfo) {
        String packageName = requestBasicInfo.getApplicationID();
        String appVersionName = requestBasicInfo.getAppVersionName();
        Integer appVersion = StringUtils.isEmpty(requestBasicInfo.getAppVersion()) ? 99999 : Integer.parseInt(requestBasicInfo.getAppVersion());

        return SwitchManageListReq.builder().packageName(packageName).switchType(switchType).appVersionName(appVersionName).appVersion(appVersion).build();
    }
}
